#include <bits/stdc++.h>
#define int long long
using namespace std;
inline int read()
{
    int f = 0, ans = 0;
    char c = getchar();
    while (!isdigit(c))
        f |= c == '-', c = getchar();
    while (isdigit(c))
        ans = (ans << 3) + (ans << 1) + c - 48, c = getchar();
    return f ? -ans : ans;
}
void write(int x)
{
    if (x < 0)
        putchar('-'), x = -x;
    if (x > 9)
        write(x / 10);
    putchar(x % 10 + '0');
}
inline void printws(int x, char ch = ' ')
{
    write(x);
    putchar(ch);
}
inline void println(int x)
{
    write(x);
    putchar('\n');
}
constexpr int N = 5e5 + 5, SUB = 1e2 + 5;
int n, K, a[N], vis[N];
int res, f[SUB], g[SUB];
pair<int, int> b[N];
signed main()
{
    freopen("sub.in", "r", stdin);
    freopen("sub.out", "w", stdout);
    n = read(), K = read();
    for (int i = 1; i <= n; ++i)
        a[i] = read();
    if (n <= 100)
    {
        res = 1e18;
        for (int s = 1; s <= n - K + 1; ++s)
        {
            memset(f, 0x3f, sizeof(f));
            f[s] = 0;
            for (int k = 1; k < K; ++k)
            {
                for (int j = s + k - 1; j < n; ++j)
                    g[j] = f[j];
                memset(f, 0x3f, sizeof(f));
                for (int i = n; i >= s + k; --i)
                    for (int j = s + k - 1; j < i; ++j)
                        f[i] = min(f[i], max(g[j], a[i] + a[j]));
            }
            for (int i = s + K - 1; i <= n; ++i)
                res = min(res, max(f[i], a[i] + a[s]));
        }
        println(res);
        return 0;
    }
    // res = -1;
    // int l = 0, r = 1e18;
    for (int i = 1; i <= n; ++i)
        b[i] = {a[i], i};
    sort(b + 1, b + n + 1);
    for (int i = 1; i <= K; ++i)
    {
        vis[b[i].second] = 1;
        cerr << b[i].first << " " << b[i].second << endl;
    }
    int fir = 0, lst = 0;
    for (int i = 1; i <= n; ++i)
        if (vis[i])
        {
            if (!fir)
                fir = i;
            if (lst)
                res = max(res, a[i] + a[lst]);
            lst = i;
        }
    res = max(res, a[lst] + a[fir]);
    println(res);
    return 0;
}